package logic

import (
	"book-hub/bookrpc/bookrpc"
	"context"

	"book-hub/api/internal/svc"
	"book-hub/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CollectListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCollectListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CollectListLogic {
	return &CollectListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CollectListLogic) CollectList(req *types.CollectListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	list, err := l.svcCtx.BookRpc.CollectList(l.ctx, &bookrpc.CollectListRequest{
		UserId: req.UserId,
	})
	if err != nil {
		return nil, err
	}
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "小说收藏列表查询成功",
		Code:    200,
		Data:    list,
	}, nil
}
